﻿using Huang.Project.Entity;
using Huang.Project.Entity.POCOModel;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace HPIT.MemberPoint.Business
{
    /// <summary>
    /// 从线程中获取数据访问上下文，保证线程内实例唯一
    /// </summary>
    public class ContextFactory
    {
        public static DbContext GetCurrentContext()
        {
            DbContext context = CallContext.GetData("MemberPoint") as DbContext;
            if (context == null)
            {
                context = new IntegralEntityModel();
                CallContext.SetData("MemberPoint", context);
            }
            return context;
        }
    }
}
